package com.flycent.hqhs.ui;

import net.tsz.afinal.FinalActivity;
import net.tsz.afinal.annotation.view.ViewInject;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.flycent.hqhs.App;
import com.flycent.hqhs.Constants;
import com.flycent.hqhs.R;
import com.flycent.hqhs.util.PackageInfoUtil;

/**
 * 关于我们
 * @author fbl
 */
public class AboutActivity extends BackableTitleBarActivity{
	@ViewInject(id = R.id.app_version_text) TextView mVersionText;
	@ViewInject(id = R.id.about_relat1 , click = "butClick") RelativeLayout mWebRelat;
	@ViewInject(id = R.id.about_relat2 , click = "butClick") RelativeLayout mPhoneRelat;

	@Override
	protected void onCreate(Bundle savedInstance) {
		super.onCreate(savedInstance);
		setContentView(R.layout.activity_about);
		FinalActivity.initInjectedView(this);
		getTitleBar().setTitle(R.string.title_about);

		mVersionText.setText("V"+PackageInfoUtil.getVersionName(App.getInstance()));

	}

	public void butClick( View v){
		if( v == mWebRelat) {
			toWeb(Constants.IP);
		}

		if( v == mPhoneRelat) {
			toPhone("400-8888888");
		}


	}

	private void toPhone(String PhoneNum) {
		if(PhoneNum!=null ){
			Uri uri = Uri.parse("tel:"+PhoneNum); 
			Intent it = new Intent(Intent.ACTION_DIAL, uri);   
			startActivity(it);  			     	        
		}

	}

	private void toWeb(String url) {

		if(url!=null ){
			//跳到外部浏览器
			//						Uri uri = Uri.parse(url); 
			//						Intent it  = new Intent(Intent.ACTION_VIEW,uri); 
			//						startActivity(it); 	

			//跳到内部webview
			Intent intent = new Intent(AboutActivity.this,WebViewActivity.class);
			intent.putExtra("url", url);
			startActivity(intent);
		}

	}

}
